package com.uchengwang.ui.view;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;

import com.uchengwang.R;
import com.uchengwang.functions.image.ImageManager;

import cn.jzvd.JZVideoPlayerStandard;


/**
 * Created by yiwei on 16/5/23.
 */
public class CycleVideoView extends LinearLayout {

    public JZVideoPlayerStandard videoPlayer;
    public ImageView videoCover;
    public ProgressBar videoProgress;
    public ImageView videoButton;

//    public VideoLoadTarget videoTarget;
//    public VideoProgressTarget progressTarget;

    private static final int STATE_IDLE = 0;
    private static final int STATE_ACTIVED = 1;
    private static final int STATE_DEACTIVED = 2;
    private int videoState = STATE_IDLE;

    private int postion;;
    private String videoId;

    private String videoLocalPath;

    public CycleVideoView(Context context) {
        super(context);
        init();
    }

    public CycleVideoView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public CycleVideoView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    public void setPostion(int pos) {
        postion = pos;
    }

    public void setVideoUrl(String videoId){
        this.videoId = videoId;//视频id  通过视频id获取视频地址播放
    }

    public void setVideoCoverUrl(String imgUrl){
        if (!TextUtils.isEmpty(imgUrl)){
            ImageManager.getInstance().setRoundSize(2).loadImage(getContext(), videoCover, imgUrl, ImageManager.ImageType.ROUND);
        }
    }

    private void init() {
        inflate(getContext(), R.layout.layout_video, this);
        videoPlayer =  findViewById(R.id.play_video);
        videoCover =  findViewById(R.id.iv_video_cover);
    }



}
